package jp.design.patterns.factory.factorys;

import jp.design.patterns.factory.entity.EmailSender;
import jp.design.patterns.factory.entity.ExpressSender;
import jp.design.patterns.factory.entity.SmsSender;
import jp.design.patterns.factory.interfac.ISender;

/**
 *
 * 发送工厂
 *
 * @author: Jp
 * @date: 2022/9/15
 **/
public class SendFactory {

    /**
     *
     * 普通简单工厂模式
     *
     * @author: Jp
     * @date: 2022/9/15
     */
    public ISender produce(String type) {
        if (type == null) {
            return null;
        } else if (ISender.EMAIL.equalsIgnoreCase(type)) {
            return new EmailSender();
        } else if (ISender.SMS.equalsIgnoreCase(type)) {
            return new SmsSender();
        } else if (ISender.EXPRESS.equalsIgnoreCase(type)) {
            return new ExpressSender();
        } else {
            return null;
        }
    }

    //======================== 多方法工厂模式 ========================//

    public ISender produceSms(){
        return new SmsSender();
    }

    public ISender produceEmail(){
        return new EmailSender();
    }

    public ISender produceExpress() {
        return new ExpressSender();
    }


}
